package com.monitor.action.user;

import java.io.PrintWriter;

import com.monitor.action.MonitorActionSupport;
import com.monitor.po.Location;
import com.monitor.service.LocationService;
import com.monitor.util.Constants;
import com.monitor.util.Pager;

public class LocationAction extends MonitorActionSupport {
	private static final long serialVersionUID = 3515736223886828390L;
	private int cPage;
	private long uid;
	private Pager<Location> locations;
	private LocationService locationService;
	private String lat;
	private String lon;
	private long lid;

	@Override
	public String execute() throws Exception {
		cPage = cPage < 1 ? 1 : cPage;
		long _uid = getUid(uid);
		locations = locationService.getLocationByUid(_uid, Constants.DEFAULT_PAGESIEZE, cPage);
		return SUCCESS;
	}

	public String locationDetail() throws Exception {
		return SUCCESS;
	}

	public void deleteLocation() throws Exception {
		long _uid = getUid(uid);
		PrintWriter out = getWriter();
		boolean success = locationService.deleteLocation(_uid, lid);
		if (success) {
			out.print("success");
		} else {
			out.print("failed");
		}
		out.flush();
		out.close();
	}

	public int getcPage() {
		return cPage;
	}

	public void setcPage(int cPage) {
		this.cPage = cPage;
	}

	public long getUid() {
		return uid;
	}

	public void setUid(long uid) {
		this.uid = uid;
	}

	public Pager<Location> getLocations() {
		return locations;
	}

	public void setLocations(Pager<Location> locations) {
		this.locations = locations;
	}

	public LocationService getLocationService() {
		return locationService;
	}

	public void setLocationService(LocationService locationService) {
		this.locationService = locationService;
	}

	public String getLat() {
		return lat;
	}

	public void setLat(String lat) {
		this.lat = lat;
	}

	public String getLon() {
		return lon;
	}

	public void setLon(String lon) {
		this.lon = lon;
	}

	public long getLid() {
		return lid;
	}

	public void setLid(long lid) {
		this.lid = lid;
	}

}
